type platformType = "fb" | "google" | "unity" | "vungle" | "applovin" | "ironsource"

/** 跳转类型 */
export enum InstallType {
    /** 正常跳转 */
    None = 1,
    /** 全局跳转 */
    Global = 2,
    /** 自动跳转 */
    Auto = 4,
    /** 诱导跳转 */
    Induce = 8
}

export default class GtPlayable {
  constructor(){
    this.initChannel()
  }

  _channel: platformType = null

  private static _instance: GtPlayable = null
  public static get instance() {
    if (!GtPlayable._instance) GtPlayable._instance = new GtPlayable()
    return GtPlayable._instance
  }

  initChannel() {
    //@ts-ignore
    if (typeof FbPlayableAd !== "undefined") {
      this.channel = "fb"
    }
    //@ts-ignore
    else if (typeof applovin !== "undefined") {
      this.channel = "applovin"
    }
    //@ts-ignore
    else if (typeof google !== "undefined") {
      this.channel = "google"
    } else {
      this.channel = null
    }

    console.log("当前平台:",this.channel)
  }

  get channel(): platformType {
    return this._channel
  }
  set channel(value: platformType) {
    this._channel = value
  }

  install(installType:InstallType = InstallType.None){
    console.log("install")
    switch(this.channel){
      case "fb":{
        //@ts-ignore
        FbPlayableAd.onCTAClick()
        break
      }
      default:{
        
      }
    }
  }
}

export const gtPlayable = GtPlayable.instance
